<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增-表与rpc接口映射关系')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>【手动创建】
            该方式不是基于表，会生成controller层，service层、DAO层及前端HTML文件，不会生成实体类、mapper.xml文件。<br>
            主要用于当前功能不涉及本地表时，调用其他系统RPC接口的情况.</span>
        <form class="form-horizontal m" id="form-table-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">主要功能名称：</label>
                <div class="col-sm-8">
                    <input name="tableName" class="form-control" type="text" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>提示：填写英文单词，首字母大写驼峰式，用于生成类名。<br>
                        例如：日志记录功能，LogRecord。会生成LogRecordController、ILogRecordService、LogRecordServiceImpl...</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">功能描述：</label>
                <div class="col-sm-8">
                    <input name="functionName" class="form-control" type="text">
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>提示：如功能名称为LogRecord，功能描述为记录日志。</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">RPC接口：</label>
                <div class="col-sm-8">
                    <select id="interfaceId" name="interfaceId" class="form-control m-b">
                        <option value="0">请选择</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>提示：此为调用到的RPC接口信息，可选项。暂时支持最多选一个，可在【表与RPC接口关系】菜单中进一步设置。</span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/table"
        $("#form-table-add").validate({
            focusCleanup: true
        });

        $.operate.post(ctx + "system/interface/list",{},function(result){
            if (result.code === 0) {
                $("#interfaceId").html(createInterfaceOptionsHtml(result));
            }else{
                alert(result.msg);
            }
        });
        function createInterfaceOptionsHtml(result){
            var html="<option value=\"\">请选择</option>";
            if(result.rows&&result.rows.length>0){
                for(var i = 0;i<result.rows.length;i++){
                    html+="<option value='"+result.rows[i].id+"'>"+result.rows[i].fullName+"</option>";
                }
            }
            return html;
        }

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(ctx + "tool/gen/create", $('#form-table-add').serialize());
            }
        }
    </script>
</body>
</html>